#include "nodeStatus.h"

int NodeStatusM::serialize(int messageType, char * message)
{
	return 0;
}

int NodeStatusM::deseralize(int messageType, const std::string & message)
{
	Document doc;
	doc.Parse(message.c_str());
	assert(doc.IsObject());

	assert(doc.HasMember("node_name"));
	assert(doc["node_name"].IsArray());

	rapidjson::Value& nodes = doc["node_name"];
	for (int i = 0; i < nodes.Size(); i++) 
	{
		NodeStatus nodestatus_;
		nodestatus_.nodeName = nodes[i]["name"].GetString();
		nodestatus_.ping = nodes[i]["ping"].GetDouble();
		nodeStatus_.push_back(nodestatus_);
	}
	return 0;
}
